<?php
function controller_produk($config) {
    $db = new db($config);
	//produk
    $uploaddir = $config['image_path'].'produk'.DIRECTORY_SEPARATOR;
	$limitedext = array("jpg","jpeg","png","bmp");
	$cfiles = 0;
	$gambar = array();
	$files = scandir($uploaddir.'produk'.DIRECTORY_SEPARATOR);
	for($i = 0; $i < count($files); $i++) {
		$file = $files[$i];
		$getExt = explode('.',$file);
		$file_ext = $getExt[count($getExt)-1];
		if (in_array($file_ext,$limitedext)) {
			$img = $config['image_url'].'produk/produk/'.$file;
			array_push($gambar, $img);
		}
	}
	$param['produk'] = $gambar;
	//sponsor
    $uploaddir = $config['image_path'].'produk'.DIRECTORY_SEPARATOR;
	$limitedext = array("jpg","jpeg","png","bmp");
	$cfiles = 0;
	$gambar = array();
	$files = scandir($uploaddir.'sponsor'.DIRECTORY_SEPARATOR);
	for($i = 0; $i < count($files); $i++) {
		$file = $files[$i];
		$getExt = explode('.',$file);
		$file_ext = $getExt[count($getExt)-1];
		if (in_array($file_ext,$limitedext)) {
			$img = $config['image_url'].'produk/sponsor/'.$file;
			array_push($gambar, $img);
		}
	}
	$param['sponsor'] = $gambar;
	//kontak
	$result = $db->query( "SELECT * FROM `kontak` WHERE page = 'toko'" );
	$param['kontak'] = $result[0];
	//link
	$result = $db->query( "SELECT online FROM `footer` WHERE 1" );
	$param['online'] = $result[0]['online'];
	//
	view_produk($config, $param);
}
